<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // 数组的展开语法
    let arr_one = [1, 2, 3, 4, 5];
    let arr_two = [...arr_one, 3, 4, 7, 8];
    console.log(arr_one);
    console.log(arr_two); //[1, 2, 3, 4, 5, 3, 4, 7, 8]

    // 对象的展开语法
    let obj_one = { name: "小灰" };
    let obj_two = { ...obj_one, age: 17 };

    console.log(obj_two);

    // 应用:修改文件上传的基础配置
    function upload(params) {
      let config = { type: "*.jpeg,*.png", size: 10000 };
        // 后面出现的数据会覆盖前面的数据
        config = { ...config, ...params };
      console.log(config);
    }
    console.log(upload({ type: "*.gif", size: 2000 }));
  </script>
</html>
